<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/style.css"/>">

<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
</head>
<body>
	<script type="text/javascript">
		$(function() {
			//新建医疗卡
			$("#btn-new").linkbutton({
				onClick : function() {
					$('#cybrname').textbox("clear");
					$('#cybrAge').textbox("clear");
					$('#cybrIdcard').textbox("clear");
					$('#cynrAddress').textbox("clear");
				}
			});

			//关闭医疗卡
			$("#btn-cancel").linkbutton({
				onClick : function() {
					$('#win-card').window('close');

				}
			});

			//添加医疗卡信息
			$("#btn-handle").linkbutton({
				onClick : function() {
					var title = $('#win-card').window("options").title;

					$("#form-cardAdd").form('submit', {
						url : 'addcrad',
						onSubmit : function() {
							return $(this).form("validate");
						},
						success : function(data) {
							var json = eval("(" + data + ")");
							$.messager.alert("提示", json.reason);
							//关闭窗口
							$('#win-card').window('close');
							//重新加载数据					
							$(this).form("clear");
						}
					});

				}

			});

			//通过onChange动态联动设置名字和身份证
			$("#cybrIdcard").textbox({
				onChange : function(idcard, o) {
					$.getJSON('idcardyz', {
						'idcard' : idcard
					}, function(data) {
						$("#CyGender").textbox('setValue', data.brSex);
						$("#cybrAge").textbox('setValue', data.brAge);
						$("#cynrAddress").textbox('setValue', data.brAddress);
					});
				}
			})

			//设置text须要验证
			$("input[type=text]").validatebox();

			$.extend($.fn.validatebox.defaults.rules, {
				idcard : {// 验证身份证
					validator : function(value) {
						return /^\d{15}(\d{2}[A-Za-z0-9])?$/i.test(value);
					},
					message : '身份证号码格式不正确'
				}
			});
		})
	</script>

	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',height:'35px',border:false">
			<div class="btn-add">
				<a id="btn-new" class="easyui-linkbutton"
					data-options="iconCls:'icon-add',width: '80px'">新建</a>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <a
					id="btn-handle" class="easyui-linkbutton"
					data-options="iconCls:'icon-handle',width: '80px'">办卡处理</a> &nbsp;

				<a id="btn-cancel" class="easyui-linkbutton"
					data-options="iconCls:'icon-cancel',width: '80px'"
					href="javascript:$('#win-card').window('close');">取消</a>

			</div>
		</div>
		<div data-options="region:'center'" style="padding: 10px;">
			<form id="form-cardAdd" method="post">
				<table>
					<tr>
						<td><input readonly="readonly" value="${MedicalCardId}"
							name="ylkNo" class="easyui-textbox"
							data-options="label: '卡号：', width: 200"></td>
					</tr>
					<tr>
						<td><input id="cybrname" name="brName" class="easyui-textbox"
							data-options="label: '病人姓名：', width: 200"></td>
					</tr>

					<tr>
						<td><input id="cybrIdcard" name="brIdcard"
							class="easyui-textbox" validtype="idcard"
							data-options="label: '病人身份证：', width: 240"></td>
					</tr>

					<tr>
						<td><select readonly="readonly" id="CyGender" name="brSex"
							class="easyui-combobox"
							data-options="label: '病人性别：',panelHeight: 'auto'"
							style="width: 200px;">
								<option value="男">男</option>
								<option value="女">女</option>
						</select></td>
					</tr>
					<tr>
						<td><input readonly="readonly" id="cybrAge" name="brAge" class="easyui-textbox"
							data-options="label: '病人年龄：', width: 200"></td>
					</tr>

					<tr>
						<td><input readonly="readonly" id="cynrAddress" name="brAddress"
							class="easyui-textbox" data-options="label: '病人地址：', width: 240"></td>
					</tr>
				</table>
			</form>
		</div>
	</div>

</body>
</html>